<?php 
namespace app\courier\controller;

use think\Controller;
use think\Session;
use app\model\Order;
use app\model\Commodity;

class Orderdo extends Controller{

	// 查看未配送订单
	public function getNotdoneOrder(){
		$orders = Order::getListByPage(10);
		$this->assign("orders",$orders);
		return $this->fetch();
	}

	// 查看正在配送订单
	public function getMyOrder(){
		$orders = Order::getMyOrder(Session::get("courier_id"),10);
		$this->assign("orders",$orders);
		return $this->fetch();
	}

	// 查看已配送订单
	public function getDoneOrder(){
		$orders = Order::getMyDoneOrder(Session::get("courier_id"),10);
		$this->assign("orders",$orders);
		return $this->fetch();
	}

	public function getOrder(){
		$order = Order::get(input("order_id"));
		$order->courier_id = Session::get("courier_id");
		$order->save();

		return getResponse(0,$order);
	}

	// 确认订单送达
	public function checkDown(){
		$order = Order::get(input("order_id"));
		$order->is_done = 1;
		$order->gmt_get = date("Y-m-d h:i:s",time());
		$order->save();
		$commodity = Commodity::get($order->commodity_id);
		$commodity->is_sold = 1;
		$commodity->save();

		return getResponse(0,$order);
	}
}

 ?>